#ifndef CENTRALWIDGET_H
#define CENTRALWIDGET_H

#include <QTableView>
#include <QStandardItemModel>
#include <QHash>

#include "globaldefine.h"

class CentralWidget : public QTableView
{
    Q_OBJECT
public:
    explicit CentralWidget(QTableView *parent = 0);
    ~CentralWidget();

    void initModel(int row);
    int  getCurrentRow();

private:
    inline int getRowCount();
    inline int getColCount();
    void createTableItems(int num);

    void initData(STOCKINFO &stockInfo, QList<QStandardItem* > &itemList);
    QColor stockDisplayColor(STOCKINFO &stockInfo);

signals:
    void sendData(STOCKINFO stockInfo);

public slots:
    void slotUpdateStockInfo(QHash<int, STOCKINFO> stockInfoHash);
    void slotClicked(const QModelIndex& index);
    void slotDoubleClicked(const QModelIndex& index);


private:
    QStandardItemModel *m_pModel;

    QHash<int, QList<QStandardItem*> > m_tableItems;
};

#endif // CENTRALWIDGET_H
